<template>
	<div>
		<div class="box">
			<h1>小型进销存系统</h1>
			用户名:<input type="text" v-model="userName"/>
			<br/>
			密码:<input type="password" v-model="password" />
			<button @click="login()">登录</button>
		</div>
	</div>
</template>

<script>
	import axios from 'axios'
	export default{
		data(){
			return{
				userName:"laozi",
				password:"123456"
			}
		},
		methods:{
			login:function(){
				var that=this;
				var url="http://localhost:8080/userLogin";
				axios.get(url,{
					params:{
						userName:that.userName,
						password:that.password
					}
				}).then(res=>{
					console.log(res);
					if(res.data.message=="OK"){
						console.log(res.data.data.realName);
						sessionStorage.setItem("realName",res.data.data.realName);
						sessionStorage.setItem("id",res.data.data.id);
						this.$router.push("/home");
					}
				})
			}
		}
	}
</script>

<style>
	.box{
		width: 600px;
		height: 500px;
		background-color: #01A3A3;
	}
</style>
